<!--
 * @页面名称:自定义modal
 * @描述: 
 * @作者: 
 * @Date:
-->
<template>
  <div>
    <el-dialog :modelValue="visible" :title="title" :width="width" :draggable="draggable" @close="close">
      <slot></slot>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="cancel">取消</el-button>
          <el-button type="primary" @click="ok">确认</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  draggable: {
    type: Boolean,
    default: true
  },
  title: {
    type: String,
    default: ""
  },
  width: {
    type: String,
    default: "450"
  },
  height: {
    type: String,
    default: "450"
  }
});

const emit = defineEmits(["update:visible", "ok", "cancel"]);
// 取消事件
const cancel = () => {
  emit("update:visible", false);
};
// 头部关闭按钮点击事件
const close = () => {
  emit("update:visible", false);
};
// 确认事件
const ok = () => {
  emit("ok");
};
</script>

<style lang="scss" scoped>
:deep(.el-dialog__body) {
  min-height: 500px;
  padding: 15px 15px 0;
  overflow: scroll;
}
:deep(.el-dialog__footer) {
  border-top: 1px solid var(--el-border-color-lighter);
}
</style>
